package com.example.qxfw.dataBaseManager.service.impl;

import com.example.qxfw.common.entity.Roles;
import com.example.qxfw.common.entity.ny.Log;
import com.example.qxfw.common.entity.xt.Permissions;
import com.example.qxfw.common.mapper.LogMapperXml;
import com.example.qxfw.common.mapper.PermissionsMapperXml;
import com.example.qxfw.common.mapper.RolesMapperXml;
import com.example.qxfw.common.util.DateUtil;
import com.example.qxfw.dataBaseManager.service.SystemManagerservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

/************************************
 *
 * @author : HuangDeYin Jolly
 * @since : JDK 11
 * @Date : 2023/7/7  星期五   11:41
 * @description : 此类用来
 ***************************************/
@Service
public class SystemManagerServiceImpl implements SystemManagerservice {

    @Autowired
    private LogMapperXml logMapperXml;

    @Autowired
    private RolesMapperXml rolesMapperXml;

    @Autowired
    private PermissionsMapperXml permissionsMapperXml;

    @Override
    public List<Log> querySelect(final String startTime, final String endTime, final String userName) {
        Timestamp startTimestamp = DateUtil.localDateTimeToTimestamp(DateUtil.stringToLocalDateTime(startTime));
        Timestamp endTimestamp = DateUtil.localDateTimeToTimestamp(DateUtil.stringToLocalDateTime(endTime));
        return this.logMapperXml.querySelect(startTimestamp,endTimestamp,userName);
    }

    @Override
    public Integer deleteLogByIdList(final List<String> idList) {
        return this.logMapperXml.deleteByIdList(idList);
    }

    @Override
    public Integer clearLog() {
        return this.logMapperXml.clearLog();
    }

    @Override
    public List<Log> getAllLog() {
        return this.logMapperXml.selectList(null);
    }

    @Override
    public List<Roles> getAllRoles() {
        return this.rolesMapperXml.getAll();
    }

    @Override
    public List<Permissions> getAllPermissions() {
        return this.permissionsMapperXml.getAllPermissions();
    }
}
